<?php
//$q=$_GET["q"];
$q = $_POST["data"];

$con = mysql_connect('localhost', 'root', '');
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("projectdatabase", $con);
$q = json_decode($q);
//$sql="SELECT * FROM Diagram WHERE svgXML = '".$q."'";
$sql = "INSERT INTO diagram (diagramname,diagramlink,userid) VALUES ('".$q[0]."','".$q[1]."','".$q[2]."')";

$result = mysql_query($sql);
//echo "yay\n";
//echo $result;
/*
echo "<table border='1'>
<tr>
<th>Firstname</th>
<th>Lastname</th>
<th>Age</th>
<th>Hometown</th>
<th>Job</th>
</tr>";

while($row = mysql_fetch_array($result))
  {
  echo "<tr>";
  echo "<td>" . $row['svgXML'] . "</td>";
//  echo "<td>" . $row['LastName'] . "</td>";
  //echo "<td>" . $row['Age'] . "</td>";
 // echo "<td>" . $row['Hometown'] . "</td>";
//  echo "<td>" . $row['Job'] . "</td>";
  echo "</tr>";
  }
echo "</table>";
*/

//$row = mysql_fetch_array($result);
//echo $row['svgXML'];
//echo serialize($q);
echo $result;
mysql_close($con);
?>
